﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using UIShare;

using EFong.View.Customer;
using EFong.View.FlightTicket;
using EFong.View.TrainTicket;
using EFong.View.Vendor;
using EFong.View.BankAccount;
using EFong.View.Project;
using EFong.View.Base;
using EFong.View.HotelBooking;
using EFong.View.OtherBusiness;
using EFong.View.Documentation;
using EFong.View.Financing;
using EFong.View.Security;
using EFong.View.IntergralExchange;
using EFong.View.Report;
using EFong.View.TouringParty;
using EFong.View.TourVendor;
using EFong.View.Data;

namespace EFong.View
{
    public partial class Frm_Main : BasicForm
    {
        public Frm_Main()
        {
            InitializeComponent();

            FormOpener.MainForm = this;
        }

        protected override void LoadDatas()
        {
            AppParameters.AllowEditCustomer = true;
            this.Text = AppParameters.SystemName;

            bool customerEdit = false;

            foreach (Contract.RoleAuthorizedItem roleAuthorizedItem in AppParameters.LoginUser.Role.Authorities)
            {
                if (roleAuthorizedItem.Allow) 
                {
                    switch (roleAuthorizedItem.AuthorizedItem.Name)
                    {
                        case "新增客户":
                            customerEdit = true;
                            break;
                        case "修改客户":
                            customerEdit = true;
                            break;
                    }
                    continue;
                }

                switch (roleAuthorizedItem.AuthorizedItem.Name)
                {
                    case "新增客户":
                        break;
                    case "修改客户":
                        //bbt_Customer.Enabled = false;
                        AppParameters.AllowEditCustomer = false;
                        break;
                    case "供应商管理":
                        bbt_Vendor.Enabled = false;
                        break;
                    case "其他经营项目管理":
                        bbt_Project.Enabled = false;
                        break;
                    case "线路管理":
                        bbt_TourVendor.Enabled = false;
                        break;
                    case "线路查询":
                        bbt_TourSearch.Enabled = false;
                        break;
                    //case "保险单管理":
                    //    bbt_InsurancePolicy.Enabled = false;
                    //    break;

                    //case "行程单管理":
                    //    bbt_JourneyOrder.Enabled = false;
                    //    break;

                    //case "飞机票预定":
                    //    bbt_Flight.Enabled = false;
                    //    break;

                    //case "火车票预定":
                    //    bbt_TrainTicket.Enabled = false;
                    //    break;

                    //case "酒店预订":
                    //    bbt_HotelBooking.Enabled = false;
                    //    break;

                    case "自助团":
                        bbtTourType.Enabled = false;
                        break;

                    //case "其他经营项目":
                    //    bbt_OtherBusiness.Enabled = false;
                    //    break;

                    //case "积分兑换":
                    //    bbt_IntergralExchange.Enabled = false;
                    //    break;

                    case "客户结算":
                        bbt_FlightCustomerSettlement.Enabled = false;
                        bbt_TrainCustomerSettlement.Enabled = false;
                        bbt_HotelCustomerSettlement.Enabled = false;
                        bbt_OtherCustomerSettlement.Enabled = false;
                        bbt_自助团结算.Enabled = false;
                        break;
                    case "供应商结算":
                        bbt_VendorSettlementCheck.Enabled = false;
                        bbt_VendorOtherSettlement.Enabled = false;
                        bbt_酒店返点结算.Enabled = false;
                        break;
                    case "自组团结算":
                        bbt_TouringPartySettlement.Enabled = false;
                        break;
                    case "银行账户管理":
                        bbt_BankAccount.Enabled = false;
                        bbt_现金.Enabled = false;
                        break;


                    case "汇率管理":
                        bbt_CurrencyManager.Enabled = false;
                        break;

                    case "资金调拨":
                        bbt_FundsTransfer.Enabled = false;
                        break;

                    case "其他支出":
                        bbt_OtherPayment.Enabled = false;
                        break;

                    case "角色定义":
                        bbt_RoleManager.Enabled = false;
                        break;

                    case "用户管理":
                        bbt_UserManager.Enabled = false;
                        break;

                    case "导入网站更新文件":
                        //bbt_Customer.Enabled = false;
                        break;

                    case "导出系统更新文件":
                        bbt_Export.Enabled = false;
                        break;

                    case "月结对账单":
                        bbt_月结对账单.Enabled = false;
                        break;

                    case "供应商对账单":
                        bbt_供应商对账单.Enabled = false;
                        break;
                    case "银行对账单":
                        bbt_银行对账单.Enabled = false;
                        bbt_现金对账单.Enabled = false;
                        break;
                    case "固定支出报表":
                        bbt_固定支出报表.Enabled = false;
                        break;

                    case "零散支出报表":
                        bbt_零散支出报表.Enabled = false;
                        break;

                    case "利润报表":
                        bbt_利润报表.Enabled = false;
                        break;

                    case "应收款报表":
                        bbt_应收款报表.Enabled = false;
                        break;

                    case "已收款报表":
                        bbt_已收款报表.Enabled = false;
                        break;

                    case "已付款报表":
                        bbt_已付款报表.Enabled = false;
                        break;

                    case "资金流动报表":
                        bbt_资金流动报表.Enabled = false;
                        break;
                    case "每日订单报表":
                        bbt_每日订单报表.Enabled = false;
                        bbt_机票总表.Enabled = false;
                        break;
                    case "出单统计":
                        bbt_出单统计.Enabled = false;
                        break;

                }
            }

            bbt_Customer.Enabled = customerEdit;
        }

        private void bar_Main_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            switch (e.Item.Name)
            {
                case "bbt_About"://关于
                    //FormOpener.ShowDialog(new Frm_About());
                    break;
                case "bbt_BankAccount"://银行账户管理
                    FormOpener.ShowMdiChild(new Frm_BankAccount(), bbt_BankAccount.Name);
                    break;
                case "bbt_Customer"://客户管理
                    FormOpener.ShowMdiChild(new Frm_Customer(), bbt_Customer.Name);
                    break;
                case "bbt_TourVendor"://线路管理
                    FormOpener.ShowMdiChild(new Frm_TourVendor(), bbt_TourVendor.Name);
                    break;
                case "bbt_TourSearch"://线路查询
                    FormOpener.ShowMdiChild(new Frm_TourVendorSearch(), bbt_TourSearch.Name);
                    break;
                case "bbt_Flight"://机票预订
                    FormOpener.ShowMdiChild(new Frm_FlightTicket(), bbt_Flight.Name);
                    break;
                case "bbt_HotelBooking"://酒店预订
                    FormOpener.ShowMdiChild(new Frm_HotelBooking(), bbt_HotelBooking.Name);
                    break;
                case "bbt_OtherBusiness"://其它经营项目
                    FormOpener.ShowMdiChild(new Frm_OtherBusiness(), bbt_OtherBusiness.Name);
                    break;
                case "bbt_TouringParty"://自组团
                    FormOpener.ShowMdiChild(new Frm_TouringParty(), bbt_TouringParty.Name);
                    break;
                case "bbtTourType"://自组团
                    FormOpener.ShowMdiChild(new Frm_TourItemType(), bbtTourType.Name);
                    break;
                case "bbt_Project"://其它经营项目管理
                    FormOpener.ShowMdiChild(new Frm_Project(), bbt_Project.Name);
                    break;
                case "bbt_TrainTicket"://火车票预订
                    FormOpener.ShowMdiChild(new Frm_TrainTicket(), bbt_TrainTicket.Name);
                    break;
                case "bbt_Vendor"://供应商管理
                    FormOpener.ShowMdiChild(new Frm_Vendor(), bbt_Vendor.Name);
                    break;
                case "bbt_InsurancePolicy"://保险单管理
                    FormOpener.ShowMdiChild(new Frm_InsurancePolicyManager(), bbt_InsurancePolicy.Name);
                    break;
                case "bbt_JourneyOrder"://行程单管理
                    FormOpener.ShowMdiChild(new Frm_JourneyOrderManager(), bbt_JourneyOrder.Name);
                    break;
                case "bbt_IntergralExchange"://积分兑换
                    FormOpener.ShowMdiChild(new Frm_IntergralExchange(), bbt_IntergralExchange.Name);
                    break;
                //case "bbt_CustomerSettlement"://客户结算
                //    FormOpener.ShowMdiChild(new Frm_CustomerSettlement(), bbt_CustomerSettlement.Name);
                //    break;
                case "bbt_FlightCustomerSettlement"://客户结算
                    FormOpener.ShowMdiChild(new Frm_FlightCustomerSettlement(), bbt_FlightCustomerSettlement.Name);
                    break;
                case "bbt_TrainCustomerSettlement"://客户结算
                    FormOpener.ShowMdiChild(new Frm_TrainCustomerSettlement(), bbt_TrainCustomerSettlement.Name);
                    break;
                case "bbt_HotelCustomerSettlement"://客户结算
                    FormOpener.ShowMdiChild(new Frm_HotelCustomerSettlement(), bbt_HotelCustomerSettlement.Name);
                    break;
                case "bbt_OtherCustomerSettlement"://客户结算
                    FormOpener.ShowMdiChild(new Frm_OtherCustomerSettlement(), bbt_OtherCustomerSettlement.Name);
                    break;
                case "bbt_自助团结算"://客户结算
                    FormOpener.ShowMdiChild(new Frm_TPCustomerSettlement(), bbt_自助团结算.Name);
                    break;
                case "bbt_VendorSettlementCheck"://供应商结算
                    FormOpener.ShowMdiChild(new Frm_VendorSettlement(), bbt_VendorSettlementCheck.Name);
                    break;
                case "bbt_VendorOtherSettlement"://供应商结算
                    FormOpener.ShowMdiChild(new Frm_VendorOtherSettlement(), bbt_VendorOtherSettlement.Name);
                    break;
                case "bbt_酒店返点结算"://供应商结算
                    FormOpener.ShowMdiChild(new Frm_酒店返点结算(), bbt_酒店返点结算.Name);
                    break;
                case "bbt_TouringPartySettlement":
                    FormOpener.ShowMdiChild(new Frm_TouringPartySettlement(), bbt_TouringPartySettlement.Name);
                    break;
                case "bbt_CurrencyManager"://汇率管理
                    FormOpener.ShowMdiChild(new Frm_CurrencyManager(), bbt_CurrencyManager.Name);
                    break;
                case "bbt_FundsTransfer"://资金调拨
                    FormOpener.ShowDialog(new Frm_FundsTransfer());
                    break;
                case "bbt_OtherPayment"://其它支出
                    FormOpener.ShowDialog(new Frm_OtherPayment());
                    break;
                case "bbt_供应商对账单":
                    FormOpener.ShowMdiChild(new Frm_供应商账单(), bbt_供应商对账单.Name);
                    break;
                case "bbt_固定支出报表":
                    FormOpener.ShowMdiChild(new Frm_固定费用报表(), bbt_固定支出报表.Name);
                    break;
                case "bbt_利润报表":
                    FormOpener.ShowMdiChild(new Frm_利润表(), bbt_利润报表.Name);
                    break;
                case "bbt_零散支出报表":
                    FormOpener.ShowMdiChild(new Frm_零散支出报表(), bbt_零散支出报表.Name);
                    break;
                case "bbt_已付款报表":
                    FormOpener.ShowMdiChild(new Frm_已付款报表(), bbt_已付款报表.Name);
                    break;
                case "bbt_已收款报表":
                    FormOpener.ShowMdiChild(new Frm_已收款报表(), bbt_已收款报表.Name);
                    break;
                case "bbt_银行对账单":
                    FormOpener.ShowMdiChild(new Frm_银行对账单(), bbt_银行对账单.Name);
                    break;
                case "bbt_现金对账单":
                    FormOpener.ShowMdiChild(new Frm_现金对账单(), bbt_现金对账单.Name);
                    break;
                case "bbt_现金":
                    FormOpener.ShowMdiChild(new Frm_现金(), bbt_现金.Name);
                    break;
                //case "bbt_应付款报表":
                //    FormOpener.ShowMdiChild(new Frm_应付款报表(), bbt_应付款报表.Name);
                //    break;
                case "bbt_应收款报表":
                    FormOpener.ShowMdiChild(new Frm_应收款报表(), bbt_应收款报表.Name);
                    break;
                case "bbt_月结对账单":
                    FormOpener.ShowMdiChild(new Frm_月结对账单(), bbt_月结对账单.Name);
                    break;
                case "bbt_资金流动报表":
                    FormOpener.ShowMdiChild(new Frm_资金流动报表(), bbt_资金流动报表.Name);
                    break;
                case "bbt_每日订单报表":
                    FormOpener.ShowMdiChild(new Frm_每日订单报表(), bbt_每日订单报表.Name);
                    break;
                case "bbt_出单统计":
                    FormOpener.ShowMdiChild(new Frm_出单统计(), bbt_出单统计.Name);
                    break;
                case "bbt_机票总表":
                    FormOpener.ShowMdiChild(new Frm_机票总表(), bbt_机票总表.Name);
                    break;
                case "bbt_RoleManager"://角色管理
                    FormOpener.ShowMdiChild(new Frm_Role(), bbt_RoleManager.Name);
                    break;
                case "bbt_UserManager"://用户管理
                    FormOpener.ShowMdiChild(new Frm_User(), bbt_UserManager.Name);
                    break;

                case "bbt_Export"://导出系统更新文件
                    FormOpener.ShowDialog(new Frm_DataExport());
                    break;
                case "bbt_Import"://导出系统更新文件
                    FormOpener.ShowDialog(new Frm_DataImport());
                    break;
                default:
                    break;
            }
        }

    }
}
